package client;

import cad.Connexion;
import java.awt.Toolkit;
import java.io.FileInputStream;
import java.io.InputStream;
import sun.audio.AudioPlayer;
import sun.audio.AudioStream;
import java.sql.*;

public class MenuPrincipal extends javax.swing.JFrame {

    public Connexion co;
    /**
     * Creates new form MenuPrincipal
     */
    public MenuPrincipal() {
        initComponents();
        //Permet d'éviter les redimensionnements de la fenêtre
        setResizable(false);
        setLocation(Toolkit.getDefaultToolkit().getScreenSize().width/2-getWidth()/2,
                Toolkit.getDefaultToolkit().getScreenSize().height/2-getHeight()/2);
        
        //Connexion à la base de données sfdb
        try {
            co = new Connexion();
        } catch(Exception e) {
            System.err.println("Erreur sur l'objet connexion");
        }
    }
    
    public void nouvelleGrille(){
        setVisible(false);
        new DialogueTailleGrille(this).setVisible(true);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        labelTitre = new javax.swing.JLabel();
        boutonNouvelleSim = new javax.swing.JButton();
        boutonChargerSim = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        labelTitre.setText("SimForest");

        boutonNouvelleSim.setText("Nouvelle simulation");
        boutonNouvelleSim.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                boutonNouvelleSimMouseClicked(evt);
            }
        });
        boutonNouvelleSim.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                boutonNouvelleSimActionPerformed(evt);
            }
        });

        boutonChargerSim.setText("Charger simulation");
        boutonChargerSim.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                boutonChargerSimMouseReleased(evt);
            }
        });
        boutonChargerSim.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                boutonChargerSimActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(labelTitre)
                    .addComponent(boutonNouvelleSim, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(boutonChargerSim, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(labelTitre)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(boutonNouvelleSim)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(boutonChargerSim)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void boutonNouvelleSimActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_boutonNouvelleSimActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_boutonNouvelleSimActionPerformed

    private void boutonChargerSimActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_boutonChargerSimActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_boutonChargerSimActionPerformed

    private void boutonNouvelleSimMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_boutonNouvelleSimMouseClicked
        // TODO add your handling code here:
        nouvelleGrille();
    }//GEN-LAST:event_boutonNouvelleSimMouseClicked

    private void boutonChargerSimMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_boutonChargerSimMouseReleased
        // TODO add your handling code here:
        new DialogueChargerSimulation(null, this).setVisible(true);
        setVisible(false);
    }//GEN-LAST:event_boutonChargerSimMouseReleased

    /**
     * @param args the command line arguments
     */
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton boutonChargerSim;
    private javax.swing.JButton boutonNouvelleSim;
    private javax.swing.JLabel labelTitre;
    // End of variables declaration//GEN-END:variables
}
